class BINOP_SET_VIEW{ETP} < $RO_SET{ETP}
****
View of a binary operation between two sets. Handles union, intersection, diff and sym_diff Instead of copying the sets, it merely maintains pointers to the two sets. This view is read-only and *cannot* be used to modify the original sets. Note that it is *not* a value interface. In fact, if the original sets change, this view will automatically change. In some cases this is exactly the behavior you want; in other cases it can be a source of nasty problems. Use carefully.
_
Usage:
_____s1:_$SET{INT}_:=_#SET{INT}(|1,2,3,5|);
_____s2:_$SET{INT}_:=_#SET{INT}(|1,5,3,9|);
_____s_::=_BINOP_SET_VIEW{INT}::create_union(s1,s2);
_____#OUT+_s.str;
______--_will_print_out_the_elements_1,2,3,5,9_in_some_arbitrary_order
_____s2.delete(9);
_____#OUT+s.str;
______--_will_print_out_the_elements_1,2,3,5_in_some_arbitrary_order
_
Implementation:
_____Maintains_pointers_to_the_two_sets,_primary_and_secondary
_____The_space_of_the_final_set_is_broken_down_into:
_____Primary_set:_(_______primary_______________)__
_____Seconary_set:_______________(__________secondary_________)
_____Result:______(_p_minus_s____(_intersection_)__s_minus_p__)
____
_____The_flags_use_p_minus_s,_use_intersect_and_use_s_minus_p_indicate
_____which_part_should_be_used


Flattened version is here

Ancestors
$RO_SET{_} $STR $CONTAINER{_} $ELT{_}
$ELT RO_SET_INCL{_} COMPARE{_}



Public


Features
copy: SAME
**** Copy returns a copy of the same type of set
create(prim: $RO_SET{ETP}, sec: $RO_SET{ETP},
create_diff(prim: $RO_SET{ETP},sec: $RO_SET{ETP}): SAME
create_intersection(prim: $RO_SET{ETP},sec: $RO_SET{ETP}): SAME
create_sym_diff(prim: $RO_SET{ETP},sec: $RO_SET{ETP}): SAME
create_union(prim: $RO_SET{ETP},sec: $RO_SET{ETP}): SAME
has(e: ETP): BOOL
**** Return true if "e" belongs to this set ph = primary has e sh = secondary has e * indicates a don't care ph sh p-s p in s s-p T T => result is True if * t * T F => result is True if t * * F T => True if * * t F F => result is False

Iters
elt!: ETP


Private

attr primary: $RO_SET{ETP};
attr primary: $RO_SET{ETP};
attr secondary: $RO_SET{ETP};
****
attr secondary: $RO_SET{ETP};
****
attr use_intersect: BOOL;
**** Use elements in prim intersect sec
attr use_intersect: BOOL;
**** Use elements in prim intersect sec
attr use_p_minus_s: BOOL;
**** Use elements in prim-sec
attr use_p_minus_s: BOOL;
**** Use elements in prim-sec
attr use_s_minus_p: BOOL;
**** Use elements in sec - prim
attr use_s_minus_p: BOOL;
**** Use elements in sec - prim

The Sather Home Page